import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:maihealth/utils/shareManager.dart';
class guanPage extends StatefulWidget {
  @override
  _guanPageState createState() => _guanPageState();
}

class _guanPageState extends State<guanPage> with AutomaticKeepAliveClientMixin{
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: <Widget>[
          FlatButton(child: Text('微信'),onPressed: (){
            print('分享到微信');
            shareToPlant('分享到微信', SharedPlant.wechat);
          }),
          FlatButton(child: Text('QQ'),onPressed: (){
            print('分享到qq');
            shareToPlant('分享到qq', SharedPlant.qq);
          }),
          FlatButton(child: Text('新浪'),onPressed: (){
            print('分享到新浪');
            shareToPlant('分享到新浪', SharedPlant.weibo);
          }),
        ],
      ),
    );
  }
//分享图片
 void shareToPlant(String title,SharedPlant plant)  async{
   try {
      final ByteData bytes = await rootBundle.load('images/share.jpg');
      final Uint8List list = bytes.buffer.asUint8List();
      shareManager.shared(list, title, plant);
   } catch (e) {
     print('e====${e}');
   }
    
 }

    @override
  void initState() {
    // TODO: implement initState
    super.initState();
    print('initState');
  }
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    print('医馆销毁');
  }

  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;
}